import requests
import re

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
}
url = r'http://www.baidu.com/s'
data = {'wd': '郑州天气'}
response = requests.request('GET', url, params=data, headers=headers)
# print(response.status_code)
response.encoding = 'utf-8'
patt = r'<title>(.*?)</title>'
title = re.findall(patt, response.text)
print(title)

url2 = r'http://apis.juhe.cn/mobile/get'
data = {'key':'0e493ffc0c27b8e9e8f93efd70dd0167','phone':'18638798023','dtype':'json'}
resp=requests.get(url2,params=data,headers=headers)
resp.encoding='utf-8'
# patt = r'<title>(.*?)</title>'
# title = re.findall(patt, resp.text)
print(resp.text)

url3 = r'http://apis.juhe.cn/simpleWeather/query'
data = {'city':'郑州','key':'4d73e3244ca47fcd365d269408cf08bf'}
resp = requests.post(url3,data=data,headers=headers)
resp.encoding='utf-8'
# patt = r'<title>(.*?)</title>'
# title = re.findall(patt, resp.text)
print(resp.text)

